//
//  DSAccountViewModel.m
//  DSJY
//
//  Created by 冯华强 on 16/10/17.
//  Copyright © 2016年 dsjy. All rights reserved.
//  用户VM

#import "DSAccountViewModel.h"

@implementation DSAccountViewModel

//单例
XCYSharedInstanceM(Account);

#pragma mark - 系统回调
- (instancetype)init
{
    if (self = [super init]) {
        self.account = [NSKeyedUnarchiver unarchiveObjectWithFile:self.path];
        self.rememberUserNamePd = YES;
    }
    return self;
}

#pragma mark - get/set
- (NSString *)path
{
    if (_path == nil) {
        //设置要保存的路径
        NSString *docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
        _path = [docPath stringByAppendingPathComponent:@"Account.data"];
    }
    return _path;
}

#pragma mark -  写入用户信息
- (void)write
{
    //设置要保存的路径
    [NSKeyedArchiver archiveRootObject:self.account toFile:self.path];
}


@end
